package xdpm.nhom16.GUI;

import java.util.List;

import xdpm.nhom16.R;
import xdpm.nhom16.DTO.ChiTietDichVuDTO;

import android.content.Context;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class ChiTietMenuAdapter extends BaseAdapter
{
	private Context mContext;
	private List<ChiTietDichVuDTO> lstMenuItem;

	public ChiTietMenuAdapter(Context context, List<ChiTietDichVuDTO> inList, Handler handler)
	{
		mContext = context;
		lstMenuItem = inList;
	}

	public int getCount()
	{
		return lstMenuItem.size();
	}

	public Object getItem(int pos)
	{
		return lstMenuItem.get(pos);
	}

	public long getItemId(int pos)
	{
		return pos;
	}

	public View getView(int pos, View convertView, ViewGroup parent)
	{
		if (convertView == null)
		{
			LayoutInflater inflater = LayoutInflater.from(mContext);
			convertView = inflater.inflate(R.layout.item_menu, null);
		}

		// Get Selected Entry
		ChiTietDichVuDTO entry = lstMenuItem.get(pos);
				
		// Set Name
		TextView name = (TextView)convertView.findViewById(R.id.textMenuName);
		name.setText(entry.getTen());
		
		// Set Type
		TextView dongia = (TextView)convertView.findViewById(R.id.textMenuDonGia);
		dongia.setText(entry.getGiaTien());
		if (entry.getChuThich()!= null)	{
			TextView chuthich = (TextView)convertView.findViewById(R.id.textMenuChuThich);
			chuthich.setText(entry.getChuThich());
		}
		
		return convertView;
	}

}